package packing;

import java.util.ArrayList;
import java.util.List;

public class State{

	private double evaluationScore;
	private Container container;
	private List<Box> boxInputList;
	
	public State() {		
		super();
		boxInputList = new ArrayList<Box>();
	}
	
	public State(Container container, List<Box> boxInputList) {
		super();
		this.container = container;
		this.boxInputList = boxInputList;	
		evaluationScore =0;
	}

	public Container getContainer() {
		return container;
	}

	public void setContainer(Container container) {
		this.container = container;
	}

	public List<Box> getBoxInputList() {
		return boxInputList;
	}

	public void setBoxInputList(List<Box> boxInputList) {
		this.boxInputList = boxInputList;
	}
	
	public void addBox(Box box){
		this.boxInputList.add(box);
	}
	
	public void addAllBox(List<Box> box){
		this.boxInputList.addAll(box);
	}

	public double getEvaluationScore() {
		return evaluationScore;
	}
		
	public String evaluate(){
		int volume =0;
		String boxTxt = "";
		for(Box box : boxInputList){
			boxTxt += box.toString();
			volume+= box.getVolume();
		}
		evaluationScore  = (double)volume/(double) container.getVolume();
		String txt = "\n::: อัตราส่วนการใช้พื้นที่ : "+evaluationScore+" ( Sum Volume Of Block("+(double)volume+") / Volume Of Container("+(double) container.getVolume()+") ) :::\n"+boxTxt;
		return txt;
	}
}
